package com.ymatou.iapi.live.service;

import org.json.JSONArray;
import org.json.JSONObject;

import com.ymt.base.YmatouBaseCall;
import com.ymttest.utils.EnvSetup;

public class GetLiveHotProductListCall extends YmatouBaseCall{
	
	private static String opurl = "api/live/getlivehotproductlist";

	public GetLiveHotProductListCall() {
		super(EnvSetup.getSystemUrl("liveiapi"), opurl, "GET", "PARAM");
	}

	@Override
	public void addDefHeader() {
		client.addHeader("Accept", "text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	}
	
	/**
	 * 获取Result
	 * 
	 * @return Result
	 */
	public JSONObject getResult() {
		JSONObject Data = null;
		try {
			JSONObject jo = new JSONObject(getReturnData());
			Data = jo.getJSONObject("result");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Data;
	}
	
	/**
	 * 获取status
	 * 
	 * @return status
	 */
	public int getStatus() {
		int status = 0;
		try {
			status = new JSONObject(getReturnData()).getInt("status");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return status;
	}
	
	/**
	 * 获取Live
	 * 
	 * @return liveObject
	 */
	public JSONObject getLive() {
		JSONObject object = null;
		try {
			object = this.getResult().getJSONObject("live");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return object;
	}
	
	/**
	 * 获取prodList
	 * 
	 * @return prodList
	 */
	public JSONArray getProdList() {
		JSONArray prodList = new JSONArray();
		try {
			prodList = this.getResult().getJSONArray("products");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return prodList;
	}
}
